home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / x / volume8 / xmail / patch2.02 < prev    next >
Encoding:
Internet Message Format  |  1990-08-27  |  48.3 KB

  1. Path: uunet!samsung!sdd.hp.com!decwrl!sun-barr!newstop!sun!parns.nsc.com
  2. From: michael@parns.nsc.com (Michael Wagnitz)
  3. Newsgroups: comp.sources.x
  4. Subject: v08i097: xmail, Patch2, Part02/05
  5. Message-ID: <141430@sun.Eng.Sun.COM>
  6. Date: 28 Aug 90 07:49:22 GMT
  7. Sender: news@sun.Eng.Sun.COM
  8. Lines: 1447
  9. Approved: argv@sun.com
  10.  
  11. Submitted-by: michael@parns.nsc.com (Michael Wagnitz)
  12. Posting-number: Volume 8, Issue 97
  13. Archive-name: xmail/patch2.02
  14.  
  15. #! /bin/sh
  16. # This is a shell archive.  Remove anything before this line, then unpack
  17. # it by saving it into a file and typing "sh file".  To overwrite existing
  18. # files, type "sh file -c".  You can also feed this as standard input via
  19. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  20. # will see the following message at the end:
  21. #        "End of archive 2 (of 5)."
  22. # Contents:  Patch.02b
  23. # Wrapped by michael@harley on Mon Aug 27 12:47:26 1990
  24. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  25. if test -f 'Patch.02b' -a "${1}" != "-c" ; then 
  26.   echo shar: Will not clobber existing file \"'Patch.02b'\"
  27. else
  28. echo shar: Extracting \"'Patch.02b'\" \(46178 characters\)
  29. sed "s/^X//" >'Patch.02b' <<'END_OF_FILE'
  30. X!  cm.type = ClientMessage;
  31. X!  cm.display = XtDisplay(w);
  32. X!  cm.message_type = XInternAtom(XtDisplay(w), "KILL_SELECTION", FALSE);
  33. X!  cm.window = XtWindow(w);
  34. X!  cm.format = 32;
  35. X!  cm.data.l[0] = XA_PRIMARY;
  36. X! 
  37. X!  XSendEvent(XtDisplay(w), cm.window, TRUE, NoEventMask, (XEvent *) &cm);
  38. X! 
  39. X!  for (; *s && !isdigit(*s); s++);
  40. X!  left = s - IndexBuf;
  41. X!  for (; *s && isdigit(*s); s++);
  42. X!  right = s - IndexBuf;
  43. X! 
  44. X!  XtTextSetSelection(w, left, right);
  45. X! 
  46. X!  XtTextSetInsertionPoint(w, pos);
  47. X  } /* SetSelect */
  48. X  
  49. X  
  50. X--- 1120,1152 ----
  51. X  } /* SetPopup */
  52. X  
  53. X  
  54. X+ /*
  55. X+ ** @(#)SetPos() - restore the saved insert position of the widget
  56. X+ */
  57. X  /* ARGSUSED */
  58. X+ XtActionProc
  59. X+ SetPos(w, event, params, num_params)
  60. X+ Widget        w;
  61. X+ XEvent        *event;
  62. X+ String        *params;
  63. X+ Cardinal    *num_params;
  64. X+ {
  65. X+  XtTextSetInsertionPoint(w, SavedPos);
  66. X+ } /* SetPos */
  67. X+ 
  68. X+ 
  69. X+ /* ARGSUSED */
  70. X  /*
  71. X! ** @(#)SetSelect() - flag the index number of the selected message
  72. X  */
  73. X  XtActionProc
  74. X  SetSelect(w, event, params, num_params)
  75. X! Widget w;        /* unused */
  76. X  XEvent *event;        /* unused */
  77. X  String *params;        /* unused */
  78. X  Cardinal *num_params;    /* unused */
  79. X  {
  80. X!  markIndex(">");
  81. X  } /* SetSelect */
  82. X  
  83. X  
  84. X*** ../v1.1/callMail.c    Mon Jun  4 09:48:34 1990
  85. X--- callMail.c    Mon Aug 27 11:09:18 1990
  86. X***************
  87. X*** 32,38 ****
  88. X   * EVENT SHALL NATIONAL SEMICONDUCTOR CORPORATION BE LIABLE FOR ANY SPECIAL,
  89. X   * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  90. X   * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
  91. X!  * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  92. X   * PERFORMANCE OF THIS SOFTWARE.
  93. X   *
  94. X   * Author:  Michael C. Wagnitz - National Semiconductor Corporation
  95. X--- 32,38 ----
  96. X   * EVENT SHALL NATIONAL SEMICONDUCTOR CORPORATION BE LIABLE FOR ANY SPECIAL,
  97. X   * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  98. X   * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
  99. X!  * OR OTHER TORTUOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  100. X   * PERFORMANCE OF THIS SOFTWARE.
  101. X   *
  102. X   * Author:  Michael C. Wagnitz - National Semiconductor Corporation
  103. X***************
  104. X*** 132,145 ****
  105. X     } else if (mailpid) { 
  106. X               /* 
  107. X                * Parent : close the slave side of pty
  108. X-               *          close stdin and stdout
  109. X                *          set the mail file descriptor to append mode
  110. X                *          register mail input with X
  111. X                */
  112. X               close(slave);
  113. X-              if (mail_fd != 0)        /* if we're restarting, mail_fd IS 0 */
  114. X-                 close(0);
  115. X-              close(1);
  116. X               fcntl(mail_fd, F_SETFL, FAPPEND);
  117. X               mailInputId = XtAddInput(mail_fd, XtInputReadMask, readMail, NULL);
  118. X              } else { 
  119. X--- 132,141 ----
  120. X***************
  121. X*** 160,169 ****
  122. X               argv[0] = Mailpgm;
  123. X               execvp(Mailpgm, argv);
  124. X               /*
  125. X!               * If we fail to make contact, we must re-establish
  126. X!               * access to the terminal screen that started us for
  127. X!               * our error message, because we don't want to send
  128. X!               * it up the xmail pipe.  Also, terminate our parent.
  129. X                */
  130. X               if ((slave = open("/dev/tty", O_RDWR)) != -1) {
  131. X                  dup2(slave, 1);
  132. X--- 156,165 ----
  133. X               argv[0] = Mailpgm;
  134. X               execvp(Mailpgm, argv);
  135. X               /*
  136. X!               * If we fail to make contact, we must re-establish access to
  137. X!               * the terminal screen that started us for our error message,
  138. X!               * because we don't want to send it up the xmail pipe.
  139. X!               * Also terminate our parent.
  140. X                */
  141. X               if ((slave = open("/dev/tty", O_RDWR)) != -1) {
  142. X                  dup2(slave, 1);
  143. X***************
  144. X*** 170,177 ****
  145. X                  dup2(slave, 2);
  146. X                  perror(Mailpgm);
  147. X                 }
  148. X!              sprintf(buf, "kill -INT %s\n", &tmpName[10]);
  149. X!              system(buf);
  150. X               exit(1);
  151. X              }
  152. X  } /* callMail */
  153. X--- 166,172 ----
  154. X                  dup2(slave, 2);
  155. X                  perror(Mailpgm);
  156. X                 }
  157. X!              kill(getppid(), SIGKILL);             /* kill our parent */
  158. X               exit(1);
  159. X              }
  160. X  } /* callMail */
  161. X*** ../v1.1/callbacks.c    Mon Jun  4 09:48:36 1990
  162. X--- callbacks.c    Mon Aug 27 11:09:18 1990
  163. X***************
  164. X*** 19,25 ****
  165. X   * EVENT SHALL NATIONAL SEMICONDUCTOR CORPORATION BE LIABLE FOR ANY SPECIAL,
  166. X   * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  167. X   * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
  168. X!  * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  169. X   * PERFORMANCE OF THIS SOFTWARE.
  170. X   *
  171. X   * Author:  Michael C. Wagnitz - National Semiconductor Corporation
  172. X--- 19,25 ----
  173. X   * EVENT SHALL NATIONAL SEMICONDUCTOR CORPORATION BE LIABLE FOR ANY SPECIAL,
  174. X   * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  175. X   * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
  176. X!  * OR OTHER TORTUOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  177. X   * PERFORMANCE OF THIS SOFTWARE.
  178. X   *
  179. X   * Author:  Michael C. Wagnitz - National Semiconductor Corporation
  180. X***************
  181. X*** 28,37 ****
  182. X--- 28,41 ----
  183. X  
  184. X  
  185. X  #include "global.h"
  186. X+ #include "xmailregex.h"
  187. X  #include <sys/wait.h>
  188. X  #include <sys/stat.h>
  189. X+ #include <sys/types.h>
  190. X+ #include <sys/time.h>
  191. X  #include <pwd.h>
  192. X  
  193. X+ extern    char    otherBuf[BUFSIZ];
  194. X  
  195. X  /*
  196. X  ** @(#)Autograph() - Add user's Sign or sign autograph to outgoing mail
  197. X***************
  198. X*** 56,62 ****
  199. X  
  200. X   strcpy(tmp, "Sign");        /* Default will be to use Sign autograph, */
  201. X   if (C && *C == 'a')        /* but if asked use their sign autograph. */
  202. X!     strcpy(tmp, "sign");
  203. X   autograph = GetMailEnv(tmp);
  204. X   if (autograph) {
  205. X      for (n = 0; n < BUFSIZ - 2 && *autograph; autograph++)
  206. X--- 60,66 ----
  207. X  
  208. X   strcpy(tmp, "Sign");        /* Default will be to use Sign autograph, */
  209. X   if (C && *C == 'a')        /* but if asked use their sign autograph. */
  210. X!     tmp[0] = 's';
  211. X   autograph = GetMailEnv(tmp);
  212. X   if (autograph) {
  213. X      for (n = 0; n < BUFSIZ - 2 && *autograph; autograph++)
  214. X***************
  215. X*** 80,85 ****
  216. X--- 84,91 ----
  217. X  
  218. X  /*
  219. X  ** @(#)Done() - Send composed message - if closure data says "Deliver"
  220. X+ **        Attempt to do the task as a forked child.  Failing that,
  221. X+ **        deliver the message by system call(s).
  222. X  */
  223. X  /* ARGSUSED */
  224. X  XtCallbackProc
  225. X***************
  226. X*** 90,97 ****
  227. X  {
  228. X   Widget        shell;
  229. X   FILE        *fp;
  230. X!  char        *p, *record, *folder, *getenv();
  231. X!  char        From[BUFSIZ], Copy[BUFSIZ], s[BUFSIZ];
  232. X   int        n;
  233. X   struct stat    st_buf;
  234. X  
  235. X--- 96,104 ----
  236. X  {
  237. X   Widget        shell;
  238. X   FILE        *fp;
  239. X!  char        *ARGV[3];
  240. X!  char        *p, *q, *record, *folder, *getenv();
  241. X!  char        From[BUFSIZ], Copy[BUFSIZ], s[BUFSIZ], addressees[BUFSIZ];
  242. X   int        n;
  243. X   struct stat    st_buf;
  244. X  
  245. X***************
  246. X*** 100,112 ****
  247. X        strcmp(shell->core.name, "popup");
  248. X        shell = XtParent(shell));
  249. X   XtDestroyWidget(shell);        /* remove our popup prompt box */
  250. X  /*
  251. X! ** first, prepare the header information (in a second temporary file)
  252. X  */
  253. X!  strcat(tmpName, "_");
  254. X!  if ((fp = fopen(tmpName, "w")) != NULL) {
  255. X!     if (*Recipient)
  256. X!        fprintf(fp, "To: %s\n", alias(Recipient));
  257. X  
  258. X      if (*SubjBuf)
  259. X         fprintf(fp, "Subject: %s\n", SubjBuf);
  260. X--- 107,131 ----
  261. X        strcmp(shell->core.name, "popup");
  262. X        shell = XtParent(shell));
  263. X   XtDestroyWidget(shell);        /* remove our popup prompt box */
  264. X+ 
  265. X+  st_buf.st_size = 0;            /* (in case msg file does not exist) */
  266. X+  stat(tmpName, &st_buf);
  267. X+ 
  268. X+  if ((fp = fopen(tmpName, "a+")) != NULL) {    /* (give cat something to do) */
  269. X+     fprintf(fp, "\n");            /* ensure the last line is a blank */
  270. X+     fclose(fp);
  271. X+     if (st_buf.st_size)            /* don't count unless text was there */
  272. X+        st_buf.st_size += 1;        /* but try to be accurate for cancel */
  273. X+    }
  274. X  /*
  275. X! ** Prepare header information (in a second temporary file)
  276. X  */
  277. X!  if ((fp = fopen((char *)sprintf(s, "%s_", tmpName), "w")) != NULL) {
  278. X!     if (*Recipient) {
  279. X!        strcpy(addressees, alias(Recipient));
  280. X!        if (*addressees)
  281. X!           fprintf(fp, "To: %s\n", addressees);
  282. X!       }
  283. X  
  284. X      if (*SubjBuf)
  285. X         fprintf(fp, "Subject: %s\n", SubjBuf);
  286. X***************
  287. X*** 114,140 ****
  288. X      if (*InReply)
  289. X         fprintf(fp, "%s\n", InReply);
  290. X  
  291. X!     if (*CcBuf)
  292. X!        fprintf(fp, "Cc: %s\n", alias(CcBuf));
  293. X  
  294. X!     if (*BccBuf)
  295. X!        fprintf(fp, "Bcc: %s\n", alias(BccBuf));
  296. X  
  297. X!     fprintf(fp, "\n");            /* separate header from text */
  298. X      fclose(fp);
  299. X     }
  300. X-  tmpName[strlen(tmpName) - 1] = '\0';    /* Drop our marker for now */
  301. X  
  302. X   if (strcmp(closure, "Deliver") == 0) {
  303. X      /*
  304. X      ** mail header information and text in temporary file using sendmail
  305. X      */
  306. X!     if (*Recipient && (*SubjBuf ||
  307. X!        (stat(tmpName, &st_buf) == 0 && st_buf.st_size))) {
  308. X         if ((p = GetMailEnv("sendmail")) == NULL)
  309. X              p = XtNewString("/usr/lib/sendmail");
  310. X!        sprintf(s, "cat %s_ %s | %s -toi -om 2> /dev/null", tmpName, tmpName, p);
  311. X!        system(s);
  312. X         XtFree(p);
  313. X  /*
  314. X  ** If user has set 'record' in their .mailrc, add a message copy to that file
  315. X--- 133,176 ----
  316. X      if (*InReply)
  317. X         fprintf(fp, "%s\n", InReply);
  318. X  
  319. X!     if (*CcBuf) {
  320. X!        p = alias(CcBuf);
  321. X!        if (*p)
  322. X!           fprintf(fp, "Cc: %s\n", p);
  323. X!       }
  324. X  
  325. X!     if (*BccBuf) {
  326. X!        p = alias(BccBuf);
  327. X!        if (*p)
  328. X!           fprintf(fp, "Bcc: %s\n", p);
  329. X!       }
  330. X  
  331. X!     if ((*Recipient || *SubjBuf) && st_buf.st_size)
  332. X!        fprintf(fp, "\n");        /* separate the header from any text */
  333. X      fclose(fp);
  334. X     }
  335. X  
  336. X+  fp = fopen((char *)sprintf(s, "%s=", tmpName), "w");
  337. X+  if (fp) {            /* try to keep user from overwriting these */
  338. X+     fprintf(fp,"mv %s_ %s#_ 2> /dev/null\n", tmpName, tmpName);
  339. X+     fprintf(fp,"mv %s  %s#  2> /dev/null\n", tmpName, tmpName);
  340. X+    }
  341. X+ 
  342. X   if (strcmp(closure, "Deliver") == 0) {
  343. X      /*
  344. X      ** mail header information and text in temporary file using sendmail
  345. X      */
  346. X!     if (*addressees && (*SubjBuf || st_buf.st_size)) {
  347. X         if ((p = GetMailEnv("sendmail")) == NULL)
  348. X              p = XtNewString("/usr/lib/sendmail");
  349. X! 
  350. X!        if (fp)
  351. X!           fprintf(fp,"cat %s#_ %s# | %s -toi -om 2> /dev/null\n", tmpName, tmpName, p);
  352. X!        else {
  353. X!           sprintf(s,"cat %s_ %s | %s -toi -om 2> /dev/null", tmpName, tmpName, p);
  354. X!           system(s);
  355. X!          }
  356. X! 
  357. X         XtFree(p);
  358. X  /*
  359. X  ** If user has set 'record' in their .mailrc, add a message copy to that file
  360. X***************
  361. X*** 141,211 ****
  362. X  */
  363. X         if (record = GetMailEnv("record")) {
  364. X            p = folder = NULL;
  365. X!           if (*record == '/' || (p = GetMailEnv("outfolder")) == NULL ||
  366. X                                (folder = GetMailEnv("folder")) == NULL) {
  367. X               strcpy(Copy, record);
  368. X               if (p) XtFree(p);
  369. X              } else {
  370. X!              if (*folder == '/') {
  371. X!                 if (*record != '+')
  372. X!                    sprintf(Copy, "%s/%s", folder, record);
  373. X!                 else
  374. X!                    sprintf(Copy, "%s/%s", folder, &record[1]);
  375. X!                } else {
  376. X!                 if (*record != '+')
  377. X!                    sprintf(Copy, "%s/%s/%s", getenv("HOME"), folder, record);
  378. X!                 else
  379. X!                    sprintf(Copy,"%s/%s/%s",getenv("HOME"),folder,&record[1]);
  380. X!                }
  381. X               XtFree(folder);
  382. X               XtFree(p);
  383. X              }
  384. X-           sprintf(From, "From %s `date`", getenv("USER"));
  385. X-           sprintf(s, "echo \"%s\" >> %s;cat %s_ %s >> %s 2> /dev/null; echo \"\" >> %s",
  386. X-                               From, Copy, tmpName, tmpName, Copy, Copy);
  387. X-           system(s);
  388. X            XtFree(record);
  389. X!          }
  390. X!       } else {
  391. X         if (! *Recipient)
  392. X            Bell("No recipient specified\n");
  393. X         else
  394. X            Bell("No subject and no message\n");
  395. X        }
  396. X!    } else {
  397. X!     if (*closure == 'c') {    /* save any partial message in our dead file */
  398. X!        if ((record = GetMailEnv("DEAD")) == NULL)
  399. X!           sprintf(Copy, "%s/dead.letter", getenv("HOME"));
  400. X!        else {
  401. X!           if (*record == '/')
  402. X!              strcpy(Copy, record);
  403. X!           else if (*record != '+')    /* default path is home directory */
  404. X!                   sprintf(Copy, "%s/%s", getenv("HOME"), record);
  405. X!                else    /* dead letters will never be legal mail messages */
  406. X!                   sprintf(Copy, "%s/%s", getenv("HOME"), &record[1]);
  407. X!           XtFree(record);
  408. X!          }
  409. X!        st_buf.st_size = 0;        /* (in case msg file does not exist) */
  410. X!        if (*Recipient || *SubjBuf ||
  411. X!           (stat(tmpName, &st_buf) == 0 && st_buf.st_size)) {
  412. X!           n = st_buf.st_size;            /* remember num bytes in msg */
  413. X!           if (stat((char *)sprintf(s, "%s_", tmpName), &st_buf) == 0)
  414. X!              n += st_buf.st_size;        /* include bytes in header */
  415. X            st_buf.st_size = -1;            /* see if our target exists */
  416. X            stat(Copy, &st_buf);
  417. X-           sprintf(s, "cat %s_ %s >> %s 2> /dev/null", tmpName, tmpName, Copy);
  418. X-           system(s);
  419. X            sprintf(s, "\"%s\" [%s] (%d bytes)\n", Copy,
  420. X                   (st_buf.st_size >= 0) ? "Appended" : "New file", n);
  421. X            Bell(s);
  422. X!          } else Bell("Nothing to save in your dead letter box\n");
  423. X        }
  424. X     }
  425. X  /*
  426. X  ** remove any message text that may have been created
  427. X  */
  428. X!  sprintf(s, "rm -f %s_ %s", tmpName, tmpName);
  429. X!  system(s);
  430. X  } /* Done */
  431. X  
  432. X  
  433. X--- 177,317 ----
  434. X  */
  435. X         if (record = GetMailEnv("record")) {
  436. X            p = folder = NULL;
  437. X!           if (*record != '+' || (p = GetMailEnv("outfolder")) == NULL ||
  438. X                                (folder = GetMailEnv("folder")) == NULL) {
  439. X               strcpy(Copy, record);
  440. X               if (p) XtFree(p);
  441. X              } else {
  442. X!              if (*folder == '/')
  443. X!                 sprintf(Copy, "%s/%s", folder, &record[1]);
  444. X!              else
  445. X!                 sprintf(Copy,"%s/%s/%s",getenv("HOME"),folder,&record[1]);
  446. X               XtFree(folder);
  447. X               XtFree(p);
  448. X              }
  449. X            XtFree(record);
  450. X! 
  451. X!           sprintf(From, "From %s `date`", getenv("USER"));
  452. X!           if (fp)
  453. X!              fprintf(fp,"echo \"%s\" >> %s\ncat %s#_ %s# >> %s 2> /dev/null\n",
  454. X!                               From, Copy, tmpName, tmpName, Copy);
  455. X!           else {
  456. X!              sprintf(s,"echo \"%s\" >> %s;cat %s_ %s >> %s 2> /dev/null",
  457. X!                               From, Copy, tmpName, tmpName, Copy);
  458. X!              system(s);
  459. X!             }
  460. X!          }            /* end - if record variable is set */
  461. X! /*
  462. X! ** If there are other addresses, add copies to those files and or folders
  463. X! */
  464. X!        if (*otherBuf) {
  465. X!           FILE    *fp1;
  466. X!           /*
  467. X!           ** Prepare (aliased) header information (in a third temporary file)
  468. X!           */
  469. X!            if ((fp1 = fopen((char *)sprintf(s, "%s$", tmpName), "w"))) {
  470. X!               fprintf(fp1, "To: %s\n", Recipient);
  471. X! 
  472. X!               if (*SubjBuf)
  473. X!                  fprintf(fp1, "Subject: %s\n", SubjBuf);
  474. X! 
  475. X!               if (*InReply)
  476. X!                  fprintf(fp1, "%s\n", InReply);
  477. X! 
  478. X!               if (*CcBuf)
  479. X!                  fprintf(fp1, "Cc: %s\n", CcBuf);
  480. X! 
  481. X!               fprintf(fp1, "\n");        /* separate header from text */
  482. X!               fclose(fp1);
  483. X!              }
  484. X!           p      = GetMailEnv("outfolder");
  485. X!           folder = GetMailEnv("folder");
  486. X!           for (record = otherBuf; *record;) {
  487. X!               for (q = record; *q && *q != ','; q++);
  488. X!               n = 0;
  489. X!               if (*q == ',') {
  490. X!                  *q = '\0';
  491. X!                  n = 1;
  492. X!                 }
  493. X!               if (*record != '+' || p == NULL || folder == NULL) {
  494. X!                  strcpy(Copy, record);
  495. X!                 } else {
  496. X!                  if (*folder == '/')
  497. X!                     sprintf(Copy, "%s/%s", folder, &record[1]);
  498. X!                  else
  499. X!                     sprintf(Copy,"%s/%s/%s",getenv("HOME"),folder,&record[1]);
  500. X!                 }
  501. X! 
  502. X!               sprintf(From, "From %s `date`", getenv("USER"));
  503. X!               if (fp)
  504. X!                  fprintf(fp,"echo \"%s\" >>%s\ncat %s$ %s# >>%s 2>/dev/null\n",
  505. X!                               From, Copy, tmpName, tmpName, Copy);
  506. X!               else {
  507. X!                  sprintf(s,"echo \"%s\" >> %s\n;cat %s$ %s >> %s 2> /dev/null",
  508. X!                              From, Copy, tmpName, tmpName, Copy);
  509. X!                  system(s);
  510. X!                 }
  511. X!               if (n) *q++ = ',';
  512. X!               record = q;
  513. X!              }    /* end - for each record in otherBuf */
  514. X!           if (p) XtFree(p);
  515. X!           if (folder) XtFree(folder);
  516. X!          }    /* end - if records in otherBuf */
  517. X!       } else {            /* end - if something is there to deliver */
  518. X         if (! *Recipient)
  519. X            Bell("No recipient specified\n");
  520. X         else
  521. X            Bell("No subject and no message\n");
  522. X        }
  523. X!    } else {         /* do we want to save the message text in dead file */
  524. X!     n = st_buf.st_size;            /* remember num bytes in msg text */
  525. X!     if (n == 0 && *closure == 'c')
  526. X!        Bell("No text to save in your dead letter box\n");
  527. X!     else {
  528. X!        if (n && (*closure == 'c' || ! Confirm("REALLY discard this text"))) {
  529. X!           if ((record = GetMailEnv("DEAD")) == NULL)
  530. X!              sprintf(Copy, "%s/dead.letter", getenv("HOME"));
  531. X!           else {
  532. X!              strcpy(Copy, record);        /* take whatever is given */
  533. X!              XtFree(record);
  534. X!             }
  535. X            st_buf.st_size = -1;            /* see if our target exists */
  536. X            stat(Copy, &st_buf);
  537. X            sprintf(s, "\"%s\" [%s] (%d bytes)\n", Copy,
  538. X                   (st_buf.st_size >= 0) ? "Appended" : "New file", n);
  539. X            Bell(s);
  540. X!           if (fp)
  541. X!              fprintf(fp,"cat %s# >> %s 2> /dev/null\n", tmpName, Copy);
  542. X!           else {
  543. X!              sprintf(s, "cat %s >> %s 2> /dev/null", tmpName, Copy);
  544. X!              system(s);
  545. X!             }
  546. X!          }
  547. X        }
  548. X     }
  549. X  /*
  550. X  ** remove any message text that may have been created
  551. X  */
  552. X!   if (! fp) {                /* if we failed to make temp file */
  553. X!      sprintf(s, "rm -f %s_ %s %s$ &", tmpName, tmpName, tmpName);
  554. X!      system(s);
  555. X!     } else {            /* try to fork this off to a child process */
  556. X!      fprintf(fp, "rm -f %s#_ %s# %s= %s$\n", tmpName,tmpName,tmpName,tmpName);
  557. X!      fclose(fp);
  558. X!      switch (fork()) {
  559. X!          case -1:            /* failed, so use old fashioned way */
  560. X!                  sprintf(s, "/bin/sh %s= &", tmpName);
  561. X!                  system(s);
  562. X!                  break;
  563. X!          case 0:            /* fork succeeded - we are the child */
  564. X!                  sprintf(s, "%s=", tmpName);
  565. X!                  ARGV[0] = "/bin/sh";
  566. X!                  ARGV[1] = s;
  567. X!                  ARGV[2] = NULL;
  568. X!                  execv("/bin/sh", ARGV);
  569. X!                  break;
  570. X!         }
  571. X!     }
  572. X  } /* Done */
  573. X  
  574. X  
  575. X***************
  576. X*** 215,233 ****
  577. X  /* ARGSUSED */
  578. X  XtCallbackProc
  579. X  DoIt(w, closure, call_data)
  580. X! Widget w;
  581. X! caddr_t closure;
  582. X! caddr_t call_data;
  583. X  {
  584. X!  int    i, n;
  585. X  
  586. X  
  587. X!     sprintf(Command, "%s\n", closure);
  588. X!  if (mailpid)                /* If connections are okay,... */
  589. X!     writeMail(Command);
  590. X!  else if (strcmp(Command, "file %\n") != 0 && strcmp(Command, "inc\n") != 0)
  591. X           Bell("No mail\n");        /* But if no new mail, complain */
  592. X!       else {
  593. X           if (strcmp(mailargv[mailargc - 2], "-f") == 0) {
  594. X              mailargc -= 2;        /* throw away any folder argument */
  595. X              mailargv[mailargc] = NULL;    /* and NULL end of argument list */
  596. X--- 321,352 ----
  597. X  /* ARGSUSED */
  598. X  XtCallbackProc
  599. X  DoIt(w, closure, call_data)
  600. X! Widget        w;
  601. X! caddr_t        closure;
  602. X! caddr_t        call_data;
  603. X  {
  604. X!  int        i, n;
  605. X!  char        buf[BUFSIZ];
  606. X!  Arg        args[1];
  607. X!  LabelWidget    lw = (LabelWidget) WidgetOf(WidgetOf(WidgetOf(toplevel,
  608. X!                     "topBox"), "titleBar"), "titleBar");
  609. X  
  610. X+  sprintf(Command, "%s\n", closure);
  611. X+  if (mailpid) {                /* If connections are okay,... */
  612. X+     if ((n = match(&command_pattern, Command)) != C_FILE && n != C_NEWMAIL)
  613. X+        writeMail(Command);
  614. X+     else {                /* check for commit of any changes */
  615. X+        XtSetArg(args[0], XtNlabel, (XtArgVal) NULL);
  616. X+        XtGetValues(lw, args, ONE);
  617. X+        strcpy(buf, (char *)args[0].value);
  618. X  
  619. X!        if (strcmp(&buf[strlen(buf) - 7], "deleted") ||
  620. X!            Confirm("COMMIT all changes to this folder"))
  621. X!           writeMail(Command);
  622. X!       }
  623. X!    } else if (C_NEWMAIL != match(&command_pattern, Command))
  624. X           Bell("No mail\n");        /* But if no new mail, complain */
  625. X!      else {
  626. X           if (strcmp(mailargv[mailargc - 2], "-f") == 0) {
  627. X              mailargc -= 2;        /* throw away any folder argument */
  628. X              mailargv[mailargc] = NULL;    /* and NULL end of argument list */
  629. X***************
  630. X*** 235,241 ****
  631. X           callMail(mailargc, mailargv);    /* restart the mail connections */
  632. X           strcpy(Command, "Start");    /* Let em know we've re-started */
  633. X           UnsetNewmail(w, NULL, NULL);
  634. X!    }
  635. X  } /* DoIt */
  636. X  
  637. X  
  638. X--- 354,360 ----
  639. X           callMail(mailargc, mailargv);    /* restart the mail connections */
  640. X           strcpy(Command, "Start");    /* Let em know we've re-started */
  641. X           UnsetNewmail(w, NULL, NULL);
  642. X!         }
  643. X  } /* DoIt */
  644. X  
  645. X  
  646. X***************
  647. X*** 263,276 ****
  648. X  caddr_t closure;
  649. X  caddr_t call_data;
  650. X  {
  651. X!  union wait    status;
  652. X   Display    *dpy = XtDisplay(toplevel);
  653. X  
  654. X!  if (mailpid) {
  655. X!     sprintf(Command, "%s\n", closure);
  656. X!     writeMail(Command);
  657. X!     wait3(&status, WNOHANG, NULL);
  658. X     }
  659. X   XtDestroyWidget(toplevel);
  660. X   XCloseDisplay(dpy);
  661. X   exit(0);
  662. X--- 382,407 ----
  663. X  caddr_t closure;
  664. X  caddr_t call_data;
  665. X  {
  666. X!  Arg        args[1];
  667. X   Display    *dpy = XtDisplay(toplevel);
  668. X+  LabelWidget    lw = (LabelWidget) WidgetOf(WidgetOf(WidgetOf(toplevel,
  669. X+                     "topBox"), "titleBar"), "titleBar");
  670. X+  char        buf[BUFSIZ];
  671. X+  union wait    status;
  672. X  
  673. X!  if (mailpid) {                /* check for commit of any changes */
  674. X!     XtSetArg(args[0], XtNlabel, (XtArgVal) NULL);
  675. X!     XtGetValues(lw, args, ONE);
  676. X!     strcpy(buf, (char *)args[0].value);
  677. X! 
  678. X!     if (*closure != 'q' || strcmp(&buf[strlen(buf) - 7], "deleted") ||
  679. X!         Confirm("Changes in folder.  REALLY quit")) {
  680. X!        sprintf(Command, "%s\n", closure);
  681. X!        writeMail(Command);
  682. X!        wait3(&status, WNOHANG, NULL);
  683. X!       } else return;
  684. X     }
  685. X+ 
  686. X   XtDestroyWidget(toplevel);
  687. X   XCloseDisplay(dpy);
  688. X   exit(0);
  689. X***************
  690. X*** 279,284 ****
  691. X--- 410,417 ----
  692. X  
  693. X  /*
  694. X  ** @(#)DoSet() - send specified set request to mail and destroy current menu.
  695. X+ **         To accommodate those systems (Sony?) whose mail cannot handle
  696. X+ **         'set no' commands, convert 'set no's to unsets.
  697. X  */
  698. X  /* ARGSUSED */
  699. X  XtCallbackProc
  700. X***************
  701. X*** 293,302 ****
  702. X   if (! mailpid)                /* If connections are okay,... */
  703. X      Bell("No mail\n");            /* if no new mail, complain */
  704. X   else {
  705. X!     sprintf(buf, "set %s", w->core.name);
  706. X!     c = QueryMail(buf);
  707. X!     XtFree(c);
  708. X  
  709. X      XtDestroyWidget(XtParent(XtParent(w)));
  710. X     }
  711. X  } /* DoSet */
  712. X--- 426,444 ----
  713. X   if (! mailpid)                /* If connections are okay,... */
  714. X      Bell("No mail\n");            /* if no new mail, complain */
  715. X   else {
  716. X!     c = w->core.name;
  717. X!     if (strcmp(&c[strlen(c) - 6], "expert") == 0) {
  718. X!        XMail.expert = (*c == 'n') ? 0 : 1;
  719. X!       } else {
  720. X!        if (*c == 'n')
  721. X!           sprintf(buf, "unset %s", &c[2]);
  722. X!        else
  723. X!           sprintf(buf, "set %s", c);
  724. X  
  725. X+        c = QueryMail(buf);
  726. X+        XtFree(c);
  727. X+       }
  728. X+ 
  729. X      XtDestroyWidget(XtParent(XtParent(w)));
  730. X     }
  731. X  } /* DoSet */
  732. X***************
  733. X*** 313,325 ****
  734. X  caddr_t call_data;
  735. X  {
  736. X   XtTextPosition pos;
  737. X   int        num;
  738. X  
  739. X   if (! mailpid)
  740. X      Bell("No mail\n");
  741. X   else {
  742. X!     pos = XtTextGetInsertionPoint(WidgetOf(WidgetOf(toplevel, "topBox"), "indexWindow"));
  743. X      num = PositionToMsgNumber(pos);    /* no current message returns zero */
  744. X      if (*client_data == 'u' && IndexBuf[pos + 1] != 'D') num = 0;
  745. X      if (num) sprintf(Command, "%s %d\n", client_data, num);
  746. X      else sprintf(Command, "%s \n", client_data);
  747. X--- 455,469 ----
  748. X  caddr_t call_data;
  749. X  {
  750. X   XtTextPosition pos;
  751. X+  Widget        iw = WidgetOf(WidgetOf(toplevel, "topBox"), "indexWindow");
  752. X   int        num;
  753. X  
  754. X   if (! mailpid)
  755. X      Bell("No mail\n");
  756. X   else {
  757. X!     pos = XtTextGetInsertionPoint(iw);
  758. X      num = PositionToMsgNumber(pos);    /* no current message returns zero */
  759. X+     pos = XtTextGetInsertionPoint(iw);
  760. X      if (*client_data == 'u' && IndexBuf[pos + 1] != 'D') num = 0;
  761. X      if (num) sprintf(Command, "%s %d\n", client_data, num);
  762. X      else sprintf(Command, "%s \n", client_data);
  763. X***************
  764. X*** 328,334 ****
  765. X--- 472,495 ----
  766. X  } /* DoWith */
  767. X  
  768. X  
  769. X+ /* ARGSUSED */
  770. X  /*
  771. X+ ** @(#)DropIt() - callback to destroy the current folder popup list(s)
  772. X+ */
  773. X+ XtCallbackProc
  774. X+ DropIt(w, client_data, call_data)
  775. X+ Widget w;
  776. X+ caddr_t client_data;
  777. X+ caddr_t call_data;
  778. X+ {
  779. X+  Widget    popup = WidgetOf(WidgetOf(WidgetOf(WidgetOf(toplevel, "topBox"),
  780. X+                                  "commandPanel"), "Folder"), "popupList");
  781. X+  if (popup)
  782. X+     XtDestroyWidget(popup);
  783. X+ } /* DropIt */
  784. X+ 
  785. X+ 
  786. X+ /*
  787. X  ** @(#)GetAliasName() - retrieve alias name from button label
  788. X  */
  789. X  /* ARGSUSED */
  790. X***************
  791. X*** 396,401 ****
  792. X--- 557,586 ----
  793. X  
  794. X  
  795. X  /*
  796. X+ ** @(#)ReEdit() - Call the editMail routine to re-edit a message
  797. X+ */
  798. X+ /* ARGSUSED */
  799. X+ XtCallbackProc
  800. X+ ReEdit(w, closure, call_data)
  801. X+ Widget    w;
  802. X+ caddr_t closure;
  803. X+ caddr_t    call_data;
  804. X+ {
  805. X+  Widget    Popup = XtParent(XtParent(XtParent(XtParent(XtParent(w)))));
  806. X+  Widget    To    = WidgetOf(WidgetOf(Popup, "SubjCc"), "To");
  807. X+ 
  808. X+ 
  809. X+  XtPopdown(XtParent(XtParent(w)));    /* drop the sub-menu popup */
  810. X+  XtPopdown(Popup);            /* pop down the send popup */
  811. X+ 
  812. X+  editMail();                /* re-edit the message file */
  813. X+ 
  814. X+  XtPopup(Popup, XtGrabNone);        /* pop back the send popup */
  815. X+  XWarpPointer(XtDisplay(toplevel), None, XtWindow(To), 0, 0, 0, 0, 10, 5);
  816. X+ } /* ReEdit */
  817. X+ 
  818. X+ 
  819. X+ /*
  820. X  ** @(#)Reply() - send a reply to the author of the selected message
  821. X  **               include its text and/or copy the other recipients, if asked.
  822. X  */
  823. X***************
  824. X*** 411,416 ****
  825. X--- 596,602 ----
  826. X   Position    pos;
  827. X   String        *params, p, q, r;
  828. X   String        txt, ccList, author, subject, others, date, reference, empty;
  829. X+  Widget        sb = WidgetOf(WidgetOf(WidgetOf(toplevel,"topBox"),"commandPanel"),"Send");
  830. X   char        *us, *getlogin();
  831. X   int        erasable = 0;
  832. X   int        alwaysIgnore;
  833. X***************
  834. X*** 425,434 ****
  835. X  
  836. X      if (p = GetMailEnv("alwaysignore")) {
  837. X         XtFree(p);
  838. X!        alwaysIgnore = 1;
  839. X        } else alwaysIgnore = 0;
  840. X  
  841. X!     if (alwaysIgnore)        /* use 'alwaysignore' to decide how we print */
  842. X         sprintf(Command, "p %d", PositionToMsgNumber(pos));
  843. X      else
  844. X         sprintf(Command, "P %d", PositionToMsgNumber(pos));
  845. X--- 611,620 ----
  846. X  
  847. X      if (p = GetMailEnv("alwaysignore")) {
  848. X         XtFree(p);
  849. X!        alwaysIgnore = (index("SRA", *client_data)) ? 1 : 0;
  850. X        } else alwaysIgnore = 0;
  851. X  
  852. X!     if (alwaysIgnore)        /* do we need to include a limited copy? */
  853. X         sprintf(Command, "p %d", PositionToMsgNumber(pos));
  854. X      else
  855. X         sprintf(Command, "P %d", PositionToMsgNumber(pos));
  856. X***************
  857. X*** 477,483 ****
  858. X      for (p = txt; *p; p++) {
  859. X          if (strcmp(p, empty) == 0 || strncmp(p, "Status:", 7) == 0) break;
  860. X  
  861. X!         if (strncmp(p, "Return-Path:", 12) == 0) {
  862. X             author = p + 14;        /* step over the opening '<' chevron */
  863. X             for (p = author; *p && *p != '>'; p++);
  864. X             if (*p) *p++ = '\0';
  865. X--- 663,680 ----
  866. X      for (p = txt; *p; p++) {
  867. X          if (strcmp(p, empty) == 0 || strncmp(p, "Status:", 7) == 0) break;
  868. X  
  869. X!         if (strncmp(p, "From ", 5) == 0 ) {
  870. X!            reference = p + 5;
  871. X!            for (p = reference; *p && *p != '\n'; p++);
  872. X!            while (*(p+1) && index(" \t", *(p+1))) {
  873. X!                  *p = ' ';        /* change this newline to a space */
  874. X!                  *(p+1) = ' ';        /* change possible tab to a space */
  875. X!                  for (p++; *p && *p != '\n'; p++);
  876. X!                 }
  877. X!            if (*p) *p = '\0';
  878. X!           }
  879. X! 
  880. X!         else if (strncmp(p, "Return-Path:", 12) == 0) {
  881. X             author = p + 14;        /* step over the opening '<' chevron */
  882. X             for (p = author; *p && *p != '>'; p++);
  883. X             if (*p) *p++ = '\0';
  884. X***************
  885. X*** 490,498 ****
  886. X             if (*p) *p = '\0';
  887. X            }
  888. X  
  889. X!         else if (strncmp(p, "From:", 5) == 0) {
  890. X             reference = p + 6;
  891. X             for (p = reference; *p && *p != '\n'; p++);
  892. X             if (*p) *p = '\0';
  893. X            }
  894. X  
  895. X--- 687,700 ----
  896. X             if (*p) *p = '\0';
  897. X            }
  898. X  
  899. X!         else if (strncmp(p, "From:", 5) == 0 && ! *reference ) {
  900. X             reference = p + 6;
  901. X             for (p = reference; *p && *p != '\n'; p++);
  902. X+            while (*(p+1) && index(" \t", *(p+1))) {
  903. X+                  *p = ' ';        /* change this newline to a space */
  904. X+                  *(p+1) = ' ';        /* change possible tab to a space */
  905. X+                  for (p++; *p && *p != '\n'; p++);
  906. X+                 }
  907. X             if (*p) *p = '\0';
  908. X            }
  909. X  
  910. X***************
  911. X*** 499,504 ****
  912. X--- 701,711 ----
  913. X          else if (strncmp(p, "To:", 3) == 0) {
  914. X             others = p + 4;
  915. X             for (p = others; *p && *p != '\n'; p++);
  916. X+            while (*(p+1) && index(" \t", *(p+1))) {
  917. X+                  *p = ' ';        /* change this newline to a space */
  918. X+                  *(p+1) = ' ';        /* change possible tab to a space */
  919. X+                  for (p++; *p && *p != '\n'; p++);
  920. X+                 }
  921. X             if (*p) *p = '\0';
  922. X            }
  923. X  
  924. X***************
  925. X*** 505,510 ****
  926. X--- 712,722 ----
  927. X          else if (strncmp(p, "Subject:", 8) == 0) {
  928. X             subject = p + 9;
  929. X             for (p = subject; *p && *p != '\n'; p++);
  930. X+            while (*(p+1) && index(" \t", *(p+1))) {
  931. X+                  *p = ' ';        /* change this newline to a space */
  932. X+                  *(p+1) = ' ';        /* change possible tab to a space */
  933. X+                  for (p++; *p && *p != '\n'; p++);
  934. X+                 }
  935. X             if (*p) *p = '\0';
  936. X            }
  937. X  
  938. X***************
  939. X*** 511,516 ****
  940. X--- 723,733 ----
  941. X          else if (strncmp(p, "Cc:", 3) == 0) {
  942. X             ccList = p + 4;
  943. X             for (p = ccList; *p && *p != '\n'; p++);
  944. X+            while (*(p+1) && index(" \t", *(p+1))) {
  945. X+                  *p = ' ';        /* change this newline to a space */
  946. X+                  *(p+1) = ' ';        /* change possible tab to a space */
  947. X+                  for (p++; *p && *p != '\n'; p++);
  948. X+                 }
  949. X             if (*p) *p = '\0';
  950. X            }
  951. X          else for (; *p && *p != '\n'; p++);
  952. X***************
  953. X*** 575,581 ****
  954. X   strcpy(InReply, empty);
  955. X   if (*client_data != 's' && *reference && *date) {
  956. X      r = (*client_data == 'S') ? "Forwarding" : "In-Reply-To";
  957. X!     sprintf(InReply, "%s: Mail from '%s' dated %s", r, reference, date);
  958. X     }
  959. X  
  960. X   strcpy(SubjBuf, empty);
  961. X--- 792,798 ----
  962. X   strcpy(InReply, empty);
  963. X   if (*client_data != 's' && *reference && *date) {
  964. X      r = (*client_data == 'S') ? "Forwarding" : "In-Reply-To";
  965. X!     sprintf(InReply, "%s: Mail from '%s'\n\tdated %s", r, reference, date);
  966. X     }
  967. X  
  968. X   strcpy(SubjBuf, empty);
  969. X***************
  970. X*** 588,594 ****
  971. X   strcpy(CcBuf, ccList);
  972. X   strcpy(BccBuf, empty);
  973. X  
  974. X!  sendMail(w);
  975. X  } /* Reply */
  976. X  
  977. X  
  978. X--- 805,811 ----
  979. X   strcpy(CcBuf, ccList);
  980. X   strcpy(BccBuf, empty);
  981. X  
  982. X!  sendMail(sb);
  983. X  } /* Reply */
  984. X  
  985. X  
  986. X***************
  987. X*** 613,619 ****
  988. X   pos = XtTextGetInsertionPoint(WidgetOf(WidgetOf(toplevel, "topBox"), "indexWindow"));
  989. X   num = PositionToMsgNumber(pos);    /* no current message returns zero */
  990. X  
  991. X!  if (*cmd == 'C' || *cmd == 'S' || *cmd == 'W' || num == 0) {
  992. X      if (num) {
  993. X         sprintf(Command, "%s %d\n", cmd, num);
  994. X        } else {
  995. X--- 830,836 ----
  996. X   pos = XtTextGetInsertionPoint(WidgetOf(WidgetOf(toplevel, "topBox"), "indexWindow"));
  997. X   num = PositionToMsgNumber(pos);    /* no current message returns zero */
  998. X  
  999. X!  if (*cmd == 'C' || *cmd == 'S' || num == 0) {
  1000. X      if (num) {
  1001. X         sprintf(Command, "%s %d\n", cmd, num);
  1002. X        } else {
  1003. X*** ../v1.1/confirm.c    Mon Aug 13 12:56:26 1990
  1004. X--- confirm.c    Mon Aug 27 11:09:18 1990
  1005. X***************
  1006. X*** 0 ****
  1007. X--- 1,233 ----
  1008. X+ /*
  1009. X+  * @(#)Confirm - a Yes/No confirmation window with optional prompt argument.
  1010. X+  *
  1011. X+  * From an idea contributed by Mitchell L. Model <mlm@odi.com> on 5-17-89
  1012. X+  *
  1013. X+  * Copyright 1990 by National Semiconductor Corporation
  1014. X+  *
  1015. X+  * Permission to use, copy, modify, and distribute this software and its
  1016. X+  * documentation for any purpose is hereby granted without fee, provided that
  1017. X+  * the above copyright notice appear in all copies and that both that
  1018. X+  * copyright notice and this permission notice appear in supporting
  1019. X+  * documentation, and that the name of National Semiconductor Corporation not
  1020. X+  * be used in advertising or publicity pertaining to distribution of the
  1021. X+  * software without specific, written prior permission.
  1022. X+  *
  1023. X+  * NATIONAL SEMICONDUCTOR CORPORATION MAKES NO REPRESENTATIONS ABOUT THE
  1024. X+  * SUITABILITY OF THIS SOFTWARE FOR ANY PURPOSE.  IT IS PROVIDED "AS IS"
  1025. X+  * WITHOUT EXPRESS OR IMPLIED WARRANTY.  NATIONAL SEMICONDUCTOR CORPORATION
  1026. X+  * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED
  1027. X+  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  IN NO
  1028. X+  * EVENT SHALL NATIONAL SEMICONDUCTOR CORPORATION BE LIABLE FOR ANY SPECIAL,
  1029. X+  * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  1030. X+  * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
  1031. X+  * OR OTHER TORTUOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  1032. X+  * PERFORMANCE OF THIS SOFTWARE.
  1033. X+  *
  1034. X+  * Author:  Michael C. Wagnitz - National Semiconductor Corporation
  1035. X+  *
  1036. X+  */
  1037. X+ #include "global.h"
  1038. X+ 
  1039. X+ #define    btnsepr    7
  1040. X+ 
  1041. X+ typedef struct _result {
  1042. X+             Bool    *popflg;
  1043. X+             Bool    *var;
  1044. X+             Widget    shell;
  1045. X+                } *Result;
  1046. X+ void
  1047. X+ ProcessOneEvent(display)
  1048. X+ Display *display;
  1049. X+ {
  1050. X+  static XEvent event;
  1051. X+ 
  1052. X+  XNextEvent(display, &event);
  1053. X+  XtDispatchEvent(&event);
  1054. X+ } /* ProcessOneEvent */
  1055. X+ 
  1056. X+ 
  1057. X+ static Result
  1058. X+ MakeResult(shell, popflg, resultvar)
  1059. X+ Bool *popflg, *resultvar;
  1060. X+ Widget shell;
  1061. X+ {
  1062. X+  Result rec = (Result) malloc(sizeof(struct _result));
  1063. X+ 
  1064. X+  rec->popflg    = popflg;
  1065. X+  rec->var    = resultvar;
  1066. X+  rec->shell    = shell;
  1067. X+ 
  1068. X+  return rec;
  1069. X+ } /* MakeResult */
  1070. X+ 
  1071. X+ 
  1072. X+ /* ARGSUSED */
  1073. X+ /*
  1074. X+ ** ClearConfirm - get rid of the confirmation box.
  1075. X+ */
  1076. X+ void
  1077. X+ ClearConfirm(w, val, result)
  1078. X+ Widget w;
  1079. X+ Bool val;
  1080. X+ Result result;
  1081. X+ {
  1082. X+  Display *display = XtDisplay(w);
  1083. X+ 
  1084. X+  XtPopdown(result->shell);
  1085. X+  XtDestroyWidget(result->shell);
  1086. X+  *result->popflg = False;
  1087. X+  *result->var = val;
  1088. X+ } /* ClearConfirm */
  1089. X+ 
  1090. X+ 
  1091. X+ /* ARGSUSED */
  1092. X+ static void
  1093. X+ Yes(w, result, call_data)
  1094. X+ Widget w;
  1095. X+ Result result;
  1096. X+ caddr_t call_data;            /* unused */
  1097. X+ {
  1098. X+  ClearConfirm(w, True, result);
  1099. X+ }
  1100. X+ 
  1101. X+ 
  1102. X+ /* ARGSUSED */
  1103. X+ static void
  1104. X+ No(w, result, call_data)
  1105. X+ Widget w;                /* unused */
  1106. X+ Result result;
  1107. X+ caddr_t call_data;
  1108. X+ {
  1109. X+  ClearConfirm(w, False, result);
  1110. X+ } /* No */
  1111. X+ 
  1112. X+ 
  1113. X+ /*
  1114. X+  * Confirm - put up a window asking for confirmation.
  1115. X+  */
  1116. X+ Bool
  1117. X+ Confirm(prompt)
  1118. X+ char*    prompt;
  1119. X+ {
  1120. X+  Arg        args[4];
  1121. X+  Bool        popped_up = False, result = False;
  1122. X+  Result        resultrec;
  1123. X+  String        Translations = "<BtnDown>,<BtnUp>:\n";
  1124. X+  Widget        shell, form, label, yes, no;
  1125. X+  Window        root, child;
  1126. X+  int        root_x, root_y, child_x, child_y;
  1127. X+  int        nargs, buttons, labelwidth, yeswidth, btnborder, btnwidth;
  1128. X+  char        *query = NULL;
  1129. X+ 
  1130. X+ /*
  1131. X+ ** First, find out if expert flag is set.  If so, just return True.
  1132. X+ */
  1133. X+  if (XMail.expert)
  1134. X+     return True;
  1135. X+ /*
  1136. X+ ** Find out where the mouse is, so we can put the confirmation
  1137. X+ ** box right there.
  1138. X+ */
  1139. X+  XQueryPointer(XtDisplay(toplevel), XtWindow(toplevel), &root, &child,
  1140. X+           &root_x, &root_y, &child_x, &child_y, &buttons);
  1141. X+  /*
  1142. X+  ** Construct the confirmation box
  1143. X+  */
  1144. X+  shell=XtCreatePopupShell("Confirm",transientShellWidgetClass,toplevel,args,0);
  1145. X+ 
  1146. X+  XtSetArg(args[0], XtNtranslations, XtParseTranslationTable(Translations));
  1147. X+  XtSetArg(args[1], XtNborderWidth, (XtArgVal) 0);
  1148. X+  form = XtCreateManagedWidget("form", formWidgetClass, shell, args, TWO);
  1149. X+ 
  1150. X+  if (! prompt) label = NULL;
  1151. X+  else {
  1152. X+     if (query) XtFree(query);
  1153. X+     query = NULL;
  1154. X+     if (query = XtMalloc(strlen(prompt) + 2)) {
  1155. X+        strcpy(query, prompt);
  1156. X+        strcat(query, "?");
  1157. X+       }
  1158. X+     XtSetArg(args[0], XtNlabel, (XtArgVal) query);
  1159. X+     XtSetArg(args[1], XtNjustify, XtJustifyCenter);
  1160. X+     XtSetArg(args[2], XtNborderWidth, (XtArgVal) 0);
  1161. X+     label = XtCreateManagedWidget("prompt", labelWidgetClass, form, args, 3);
  1162. X+    }
  1163. X+ 
  1164. X+  nargs = 0;
  1165. X+  XtSetArg(args[nargs], XtNhorizDistance, (XtArgVal) btnsepr);    nargs++;
  1166. X+  if (prompt) {
  1167. X+     XtSetArg(args[nargs], XtNfromVert, (XtArgVal) label);    nargs++;
  1168. X+     XtSetArg(args[nargs], XtNvertDistance, (XtArgVal) 12);    nargs++;
  1169. X+    }
  1170. X+  yes = XtCreateManagedWidget("yes", commandWidgetClass, form, args, nargs);
  1171. X+ 
  1172. X+  nargs = 0;
  1173. X+  XtSetArg(args[nargs], XtNfromHoriz, (XtArgVal) yes);        nargs++;
  1174. X+  XtSetArg(args[nargs], XtNhorizDistance, (XtArgVal) btnsepr);    nargs++;
  1175. X+  if (prompt) {
  1176. X+     XtSetArg(args[nargs], XtNfromVert, (XtArgVal) label);    nargs++;
  1177. X+     XtSetArg(args[nargs], XtNvertDistance, (XtArgVal) 12);    nargs++;
  1178. X+    }
  1179. X+  no = XtCreateManagedWidget("no", commandWidgetClass, form, args, nargs);
  1180. X+ 
  1181. X+  if (! label)
  1182. X+     labelwidth = 0;
  1183. X+  else {
  1184. X+     XtSetArg(args[0], XtNwidth, (XtArgVal) NULL); 
  1185. X+     XtGetValues(label, args, ONE);
  1186. X+     labelwidth = args[0].value;
  1187. X+    }
  1188. X+     
  1189. X+  XtSetArg(args[0], XtNwidth, (XtArgVal) NULL); 
  1190. X+  XtSetArg(args[1], XtNborder, (XtArgVal) NULL); 
  1191. X+  XtGetValues(yes, args, TWO);
  1192. X+ 
  1193. X+  yeswidth = args[0].value;
  1194. X+  btnborder = args[1].value;
  1195. X+ 
  1196. X+  btnwidth = (labelwidth - btnsepr - (2 * btnborder)) / 2;
  1197. X+  if (btnwidth < yeswidth) btnwidth = yeswidth;
  1198. X+ 
  1199. X+  XtSetArg(args[0], XtNwidth, (XtArgVal) btnwidth); 
  1200. X+  XtSetValues(yes, args, ONE);
  1201. X+  XtSetValues(no, args, ONE);
  1202. X+ 
  1203. X+  XtRealizeWidget(shell);
  1204. X+ 
  1205. X+  XtSetArg(args[0], XtNwidth, (XtArgVal) NULL); 
  1206. X+  XtSetArg(args[1], XtNheight, (XtArgVal) NULL); 
  1207. X+  XtGetValues(shell, args, TWO);
  1208. X+ 
  1209. X+  root_x -= args[0].value / 2;
  1210. X+  root_y -= args[1].value / 2;
  1211. X+ /*
  1212. X+ ** Keep confirm popup within root window borders (don't place it off-screen)
  1213. X+ */
  1214. X+  if (root_x + args[0].value > RootWidth)
  1215. X+      root_x = RootWidth - args[0].value;
  1216. X+  if (root_x < 0) root_x = 0;
  1217. X+ 
  1218. X+  if (root_y + args[0].value > RootHeight)
  1219. X+      root_y = RootHeight - args[0].value;
  1220. X+  if (root_y < 0) root_y = 0;
  1221. X+ 
  1222. X+  XtSetArg(args[0], XtNx, (XtArgVal) root_x); 
  1223. X+  XtSetArg(args[1], XtNy, (XtArgVal) root_y); 
  1224. X+  XtSetValues(shell, args, TWO);
  1225. X+ 
  1226. X+  resultrec = MakeResult(shell, &popped_up, &result);
  1227. X+  XtAddCallback(yes, XtNcallback, Yes, resultrec);
  1228. X+  XtAddCallback(no, XtNcallback, No, resultrec);
  1229. X+ 
  1230. X+  if (XMail.bellRing)            /* ring bell if not silenced by user */
  1231. X+     XBell (XtDisplay (toplevel), 33);
  1232. X+ 
  1233. X+  XtPopup(shell, XtGrabExclusive);
  1234. X+ 
  1235. X+  popped_up = True;
  1236. X+ 
  1237. X+  while (popped_up) ProcessOneEvent(XtDisplay(shell));
  1238. X+ 
  1239. X+  return result;
  1240. X+ } /* Confirm */
  1241. X*** ../v1.1/defs.h    Mon Jun  4 09:48:36 1990
  1242. X--- defs.h    Mon Aug 27 11:09:19 1990
  1243. X***************
  1244. X*** 32,38 ****
  1245. X   * EVENT SHALL NATIONAL SEMICONDUCTOR CORPORATION BE LIABLE FOR ANY SPECIAL,
  1246. X   * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  1247. X   * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
  1248. X!  * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  1249. X   * PERFORMANCE OF THIS SOFTWARE.
  1250. X   *
  1251. X   * Author:  Michael C. Wagnitz - National Semiconductor Corporation
  1252. X--- 32,38 ----
  1253. X   * EVENT SHALL NATIONAL SEMICONDUCTOR CORPORATION BE LIABLE FOR ANY SPECIAL,
  1254. X   * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  1255. X   * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
  1256. X!  * OR OTHER TORTUOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  1257. X   * PERFORMANCE OF THIS SOFTWARE.
  1258. X   *
  1259. X   * Author:  Michael C. Wagnitz - National Semiconductor Corporation
  1260. X***************
  1261. X*** 49,67 ****
  1262. X  #include <X11/Shell.h>
  1263. X  #include <X11/Xatom.h>
  1264. X  
  1265. X! #if XtSpecificationRelease >= 4
  1266. X! /* R4 */
  1267. X! #include <X11/Xaw/Cardinals.h>
  1268. X! #include <X11/Xaw/VPaned.h>
  1269. X! #include <X11/Xaw/Form.h>
  1270. X! #include <X11/Xaw/AsciiText.h>
  1271. X! #include <X11/Xaw/TextP.h>
  1272. X! #include <X11/Xaw/Box.h>
  1273. X! #include <X11/Xaw/List.h>
  1274. X! #include <X11/Xaw/Command.h>
  1275. X! #include <X11/Xaw/Dialog.h>
  1276. X! #include <X11/Xaw/Label.h>
  1277. X! #else
  1278. X  /* R3 */
  1279. X  #include <X11/Cardinals.h>
  1280. X  #include <X11/VPaned.h>
  1281. X--- 49,55 ----
  1282. X  #include <X11/Shell.h>
  1283. X  #include <X11/Xatom.h>
  1284. X  
  1285. X! #if XtSpecificationRelease < 4
  1286. X  /* R3 */
  1287. X  #include <X11/Cardinals.h>
  1288. X  #include <X11/VPaned.h>
  1289. X***************
  1290. X*** 73,78 ****
  1291. X--- 61,78 ----
  1292. X  #include <X11/Command.h>
  1293. X  #include <X11/Dialog.h>
  1294. X  #include <X11/Label.h>
  1295. X+ #else
  1296. X+ /* R4 */
  1297. X+ #include <X11/Xaw/Cardinals.h>
  1298. X+ #include <X11/Xaw/VPaned.h>
  1299. X+ #include <X11/Xaw/Form.h>
  1300. X+ #include <X11/Xaw/AsciiText.h>
  1301. X+ #include <X11/Xaw/TextP.h>
  1302. X+ #include <X11/Xaw/Box.h>
  1303. X+ #include <X11/Xaw/List.h>
  1304. X+ #include <X11/Xaw/Command.h>
  1305. X+ #include <X11/Xaw/Dialog.h>
  1306. X+ #include <X11/Xaw/Label.h>
  1307. X  #endif
  1308. X  
  1309. X  #define    TITLE        "xmail 1."    /* program title and version string */
  1310. X***************
  1311. X*** 108,115 ****
  1312. X      Dimension    helpY;            /* help y offset from textWindow */
  1313. X      Dimension    menuX;            /* menu x offset from parent */
  1314. X      Dimension    menuY;            /* menu y offset from parent */
  1315. X-     Boolean    iconic;            /* xmail starts in withdrawn state */
  1316. X      Boolean    bellRing;        /* xmail audible bell option */
  1317. X      Boolean    mailopt_n;        /* mail option -n */
  1318. X      Boolean    mailopt_U;        /* mail option -U */
  1319. X      Boolean    Show_Last;        /* xmail show latest option -ls */
  1320. X--- 108,116 ----
  1321. X      Dimension    helpY;            /* help y offset from textWindow */
  1322. X      Dimension    menuX;            /* menu x offset from parent */
  1323. X      Dimension    menuY;            /* menu y offset from parent */
  1324. X      Boolean    bellRing;        /* xmail audible bell option */
  1325. X+     Boolean    expert;            /* do not confirm destructive acts */
  1326. X+     Boolean    iconic;            /* xmail starts in withdrawn state */
  1327. X      Boolean    mailopt_n;        /* mail option -n */
  1328. X      Boolean    mailopt_U;        /* mail option -U */
  1329. X      Boolean    Show_Last;        /* xmail show latest option -ls */
  1330. X*** ../v1.1/directory.c    Mon Jun  4 09:48:36 1990
  1331. X--- directory.c    Mon Aug 27 11:09:19 1990
  1332. X***************
  1333. X*** 19,25 ****
  1334. X   * EVENT SHALL NATIONAL SEMICONDUCTOR CORPORATION BE LIABLE FOR ANY SPECIAL,
  1335. X   * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  1336. X   * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
  1337. X!  * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  1338. X   * PERFORMANCE OF THIS SOFTWARE.
  1339. X   *
  1340. X   * Author:  Michael C. Wagnitz - National Semiconductor Corporation
  1341. X--- 19,25 ----
  1342. X   * EVENT SHALL NATIONAL SEMICONDUCTOR CORPORATION BE LIABLE FOR ANY SPECIAL,
  1343. X   * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  1344. X   * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
  1345. X!  * OR OTHER TORTUOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  1346. X   * PERFORMANCE OF THIS SOFTWARE.
  1347. X   *
  1348. X   * Author:  Michael C. Wagnitz - National Semiconductor Corporation
  1349. X***************
  1350. X*** 46,56 ****
  1351. X  String        *params;
  1352. X  Cardinal    *num_params;
  1353. X  {
  1354. X!  Arg        args[6];
  1355. X   Cardinal    label_width, path_length, n, depth, x, y;
  1356. X   DIR        *new_dir, *dirp;
  1357. X   String        name, path;
  1358. X!  Widget        menu, layout, bw;
  1359. X   char        *s, trans[BUFSIZ], tmp[BUFSIZ];
  1360. X  
  1361. X  #ifdef SUNOS_4
  1362. X--- 46,56 ----
  1363. X  String        *params;
  1364. X  Cardinal    *num_params;
  1365. X  {
  1366. X!  Arg        args[7];
  1367. X   Cardinal    label_width, path_length, n, depth, x, y;
  1368. X   DIR        *new_dir, *dirp;
  1369. X   String        name, path;
  1370. X!  Widget        menu, layout, bw, above, to_left;
  1371. X   char        *s, trans[BUFSIZ], tmp[BUFSIZ];
  1372. X  
  1373. X  #ifdef SUNOS_4
  1374. X***************
  1375. X*** 104,146 ****
  1376. X      label_width = (n=strlen(tmp)) ? XTextWidth(TextFontStr, tmp, n) + 12 : 0;
  1377. X  
  1378. X      if (label_width) {
  1379. X!     (void) sprintf(trans, b_Trans, depth, name);
  1380. X  
  1381. X!     XtSetArg(args[0], XtNwidth, label_width);
  1382. X!     XtSetArg(args[1], XtNfont, TextFontStr);
  1383. X!     XtSetArg(args[2], XtNcallback, callbacks);
  1384. X!     XtSetArg(args[3], XtNtranslations, XtParseTranslationTable(trans));
  1385. X  /*
  1386. X  ** create the menu buttons
  1387. X  */
  1388. X!     bw = NULL;
  1389. X!     for (dp = readdir(dirp); dp != NULL; dp = readdir(dirp)) {
  1390. X!         if (strcmp(dp->d_name, ".") && strcmp(dp->d_name, "..")) {
  1391. X  /*
  1392. X  ** If this 'folder file' is also a directory, mark it with a trailing slash '/'
  1393. X  */
  1394. X!            s = XtMalloc(path_length + strlen(dp->d_name) + 2);
  1395. X!            sprintf(s, "%s/%s", path, dp->d_name);
  1396. X!            if ((new_dir = opendir(s)) != NULL) {
  1397. X!               sprintf(tmp, "%s/", dp->d_name);
  1398. X!               XtSetArg(args[4], XtNlabel, tmp);
  1399. X!              } else
  1400. X!               XtSetArg(args[4], XtNlabel, dp->d_name);
  1401. X!            XtSetArg(args[5], XtNfromVert, bw);
  1402. X!            bw = XtCreateManagedWidget("menubutton",commandWidgetClass,layout,args,6);
  1403. X  /*
  1404. X  ** If this 'folder' is a directory, add a button popup menu of its files.
  1405. X  */
  1406. X!            if (new_dir) {
  1407. X!               closedir(new_dir);
  1408. X!               sprintf(trans, dir_Trans, tmp, s, depth);
  1409. X!               XtOverrideTranslations(bw, XtParseTranslationTable(trans));
  1410. X               }
  1411. X-            XtFree(s);
  1412. X            }
  1413. X         }
  1414. X-     closedir(dirp);
  1415. X-       }
  1416. X  /*
  1417. X  ** If no buttons were created for this menu, destroy the widget.
  1418. X  */
  1419. X--- 104,154 ----
  1420. X      label_width = (n=strlen(tmp)) ? XTextWidth(TextFontStr, tmp, n) + 12 : 0;
  1421. X  
  1422. X      if (label_width) {
  1423. X!        (void) sprintf(trans, b_Trans, depth, name);
  1424. X  
  1425. X!        XtSetArg(args[0], XtNwidth, label_width);
  1426. X!        XtSetArg(args[1], XtNfont, TextFontStr);
  1427. X!        XtSetArg(args[2], XtNcallback, callbacks);
  1428. X!        XtSetArg(args[3], XtNtranslations, XtParseTranslationTable(trans));
  1429. X  /*
  1430. END_OF_FILE
  1431. if test 46178 -ne `wc -c <'Patch.02b'`; then
  1432.     echo shar: \"'Patch.02b'\" unpacked with wrong size!
  1433. fi
  1434. # end of 'Patch.02b'
  1435. fi
  1436. echo shar: End of archive 2 \(of 5\).
  1437. cp /dev/null ark2isdone
  1438. MISSING=""
  1439. for I in 1 2 3 4 5 ; do
  1440.     if test ! -f ark${I}isdone ; then
  1441.     MISSING="${MISSING} ${I}"
  1442.     fi
  1443. done
  1444. if test "${MISSING}" = "" ; then
  1445.     echo You have unpacked all 5 archives.
  1446.     rm -f ark[1-9]isdone
  1447. else
  1448.     echo You still need to unpack the following archives:
  1449.     echo "        " ${MISSING}
  1450. fi
  1451. ##  End of shell archive.
  1452. exit 0
  1453.  
  1454. dan
  1455. ----------------------------------------------------
  1456. O'Reilly && Associates   argv@sun.com / argv@ora.com
  1457. Opinions expressed reflect those of the author only.
  1458.